using System;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions.CrystalReports.Engine;
using System.Windows.Forms;


namespace PrintBarcode
{
    public class ReportDAO
    {
       
        private string path;
        CrystalDecisions.Shared.TableLogOnInfo tliCurrent;        
        private UTLDB.UTLXML _xml;
       
        private string configFileName = "App.config";
        readonly string localPath = Application.StartupPath;
        public Boolean kenoi(ReportDocument rptAllCustomersOrders)
        {
            try
            {

                path = localPath + "\\" + configFileName;
                UTLDB.UTLXML _xml = new UTLDB.UTLXML(path);

                foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rptAllCustomersOrders.Database.Tables)
                {
                    
                    tliCurrent = tbCurrent.LogOnInfo;
                    if (_xml.ReadTagInfor("OptionConnection").ToString().Trim() == "2")
                    {
                        tliCurrent.ConnectionInfo.ServerName = _xml.ReadTagInfor("Server");
                        tliCurrent.ConnectionInfo.UserID = _xml.ReadTagInfor("UserID");
                        tliCurrent.ConnectionInfo.Password = _xml.ReadTagInfor("Password");
                        tliCurrent.ConnectionInfo.DatabaseName = _xml.ReadTagInfor("DataBase");

                    }
                    else
                    {
                        //tliCurrent.ConnectionInfo.ServerName = _xmlProvider.ReadTagInfor("DataSourceExpress");
                        //tliCurrent.ConnectionInfo.DatabaseName = "SalesDB";//_xmlProvider.ReadTagInfor("AttachFile");
                        //tliCurrent.ConnectionInfo.IntegratedSecurity = bool.Parse(_xmlProvider.ReadTagInfor("IntegratedSecurity"));


                    }
                    tbCurrent.ApplyLogOnInfo(tliCurrent);



                }
                return true;
            }
            catch
            {
                return false;
            }


        }


    }


}
